<?php namespace App\Services;

use Auth;
use App\Facades\Infra\AddressManager;

class AddressService{
	public function getAddress(){
		$conditions = [
			'customer_id' => Auth::user()->id
		];

		return AddressManager::getAddresses($conditions,$first = true)->get();
	}

	public function addAddress($data){

		$createData = [
			'address' => $data['address'],
			'customer_id' => Auth::user()->id
		];

		return AddressManager::createAddress($createData);
	}

	public function updateAddress($data){

		$id = $data['id'];

		$updateData = [
			'address' => $data['address']
		];

		return AddressManager::updateAddress($id,$updateData);
	}

	public function deleteAddress($data){
		$id = $data['id'];

		return AddressManager::deleteAddress($id);
	}
}